package com.Controller.servlet;


import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.sql.DAO;

import com.Model.Pojo.Users;

public class duanqitouziServlet extends HttpServlet {
	public void doPost(HttpServletRequest request, HttpServletResponse response)
	throws ServletException, IOException{
		response.setContentType("text/html");
		request.setCharacterEncoding("UTF-8");
    	response.setCharacterEncoding("UTF-8");
    	PrintWriter out = response.getWriter();
    	
    	Users user = new Users();
		HttpSession session = request.getSession();
		user = (Users)session.getAttribute("users");
    	
    	String str = request.getParameter("touzijine");
    	String ch = request.getParameter("month");
    	double money = Double.parseDouble(str);
    	int month = Integer.parseInt(ch);
    	
    	String number=user.getZhanghao();
    	
//    	int useryue = user.getYue();
//    	useryue-=money;
    	
    	double mny=money+money*month*0.05;
    	
    	DAO dao = new DAO();
//		String usernumber = user.getZhanghao();
//		String username = user.getXingming();
//		String com.sql = "update users set yue='" + useryue + "' where name='" + usernumber + "' ";
//		dao.xiugai(com.sql);
		String sql = "insert into invest(number,money,month,aftermoney)value('"+number+"','"+money+"','"+month+"','"+mny+"')";
		dao.zengjia(sql);
		
//		user.setYue(useryue);
//		session.setAttribute("users", useryue);
		
		
		response.sendRedirect("/Bank/WebPage/FrontPage/InvestmentAndFinancingPage/ShortTermInvestmentPage/ShortTermInvestment.jsp");
    	//----------------
    	
	}
}
